-
Couldn't load subscription status.
- Fork 436
Treat iolist of empty binaries as empty body #750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
37cef62 to
87f0d7e
Compare
| S = hackney_headers_new:get_value(<<"content-length">>, Headers), | ||
| {S, CT, Body0}; | ||
|
|
||
| _ when is_list(Body0) -> % iolist case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case is now handled before calling handle_body.
1e85121 to
6e5534c
Compare
|
I rebased and added some integration tests. |
6e5534c to
3580e75
Compare
src/hackney_request.erl
Outdated
| {Headers2, ReqType0, Body0, Client0}; | ||
| [] -> | ||
| {Headers2, ReqType0, Body0, Client0}; | ||
| _ when is_list(Body0) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we don't anything specif for iolist why not doing it at first level and then check for empty or not body ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I was trying to keep my changes isolated but that's a better way of doing it. Just pushed a new version.
72a51a9 to
011f3e8
Compare
011f3e8 to
1a118bf
Compare
Fixes non-POST/PUT requests with a body of [<<>>] receiving Content-Type and Content-Length headers despite not having a body.
1a118bf to
6ff6aba
Compare
Normally when the request body is empty,
handle_bodyis only called for POST and PUT requests, since other methods shouldn't haveContent-TypeandContent-Lengthheaders for empty bodies. But one case is missed in the empty body detection, an iolist containing empty binaries. The gleam hackney wrapper represents empty bodies as[<<>>], triggering this bug and causing gleam-lang/hackney#5.This PR expands the empty body detection to check if the result of
iolist_to_binaryis empty.